#ifndef UTHFUNCTION_H_
#define UTHFUNCTION_H_

#include "UTHValue.h"

namespace phnq
{
	namespace uth
	{
		class UTHArray;
		class UTHFunctionListener;
	
		class UTHFunction : public UTHValue
		{
			public:
				UTHFunction(UTHFunctionListener *listener, const void *userData=0);
				UTHFunction(UTHValue* (*)(const void*,UTHArray*), const void *userData=0);
				~UTHFunction();
				UTHValue* invoke(UTHArray* args);
				const void* getUserData();
				void serialize(stringbuf *sb);
			
			private:
				UTHFunctionListener *listener;
				UTHValue* (*callback)(const void*,UTHArray*);
				const void *userData;
			
		};
	
		class UTHFunctionListener
		{
			public:
				virtual UTHValue* invokeFunction(UTHFunction *fn, UTHArray* args) = 0;
		};
	}
}

#endif //UTHFUNCTION_H_
